/*
 * Created on 2005-01-22
 */
package dk.aiszone.lang.autosource.generatorobjects;

import java.util.List;

import dk.aiszone.lang.autosource.generatorobjects.helpers.BodyObject;
import dk.aiszone.lang.autosource.generatorobjects.helpers.ImportsList;
import dk.aiszone.lang.autosource.generatorobjects.interfaces.BodyContainer;
import dk.aiszone.lang.autosource.generatorobjects.interfaces.BodyContainerWrapper;
import dk.aiszone.lang.autosource.generatorobjects.interfaces.GeneratorObject;
import dk.aiszone.lang.autosource.generatorobjects.interfaces.SimpleBlockObject;

/**
 * <p>
 * Represention of a static area: <br>
 * <br>
 * static {<br>
 * &nbsp;&nbsp;&nbsp;&nbsp;//Insert code here <br>}<br>
 * 
 * @author <a href="mailto:ais@mail.dk">Ais</a>
 * @since 1.0
 * @version 1.0
 */
public class StaticArea extends GeneratorObject implements BodyContainerWrapper, Cloneable {

    private BodyContainer body = new BodyObject();
    private ImportsList imports = new ImportsList();

    /**
     * Default constructor for the <code>StaticArea</code>
     */
    public StaticArea() {
    // Do nothing
    }

    /**
     * Adds an <code>Import</code> to the static area.
     * 
     * @param _import
     *            <code>Import</code> needed by the static area.
     */
    public void addNeededImport(Import _import) {
        imports.addImport(_import);
    }

    @Override
    public BodyContainer appendToBody(BodyContainer part) {
        return body.appendToBody(part);
    }

    @Override
    public BodyContainer appendToBody(boolean part) {
        return body.appendToBody(part);
    }

    @Override
    public BodyContainer appendToBody(int part) {
        return body.appendToBody(part);
    }

    @Override
    public BodyContainer appendToBody(SimpleBlockObject part) {
        return body.appendToBody(part);
    }

    @Override
    public BodyContainer appendToBody(String part) {
        return body.appendToBody(part);
    }

    @Override
    public BodyContainer appendToBody(StringBuilder part) {
        return body.appendToBody(part);
    }

    @Override
    public BodyContainer appendToBodyEnd(String endPart) {
        return body.appendToBodyEnd(endPart);
    }

    @Override
    public Object clone() {
        StaticArea clone = new StaticArea();
        clone.body = (BodyObject)this.body.clone();
        clone.imports = (ImportsList)this.imports.clone();
        return clone;
    }

    /**
     * Retrieve the <code>BodyContainer</code> of the <code>StaticArea</code>.
     * 
     * @return The current <code>BodyContainer</code> of the <code>StaticArea</code>.
     */
    public BodyContainer getBody() {
        return body;
    }

    @Override
    public List<SimpleBlockObject> getBodyParts() {
        return body.getBodyParts();
    }

    /**
     * Retrieve a <code>ImportList</code> containing all the <code>Imports</code> needed by the <code>StaticArea</code>.
     * 
     * @return The needed <code>Imports</code>.
     */
    public ImportsList getNeededImports() {
        return imports;
    }

    @Override
    public boolean isBodyEmpty() {
        return body.isBodyEmpty();
    }

    @Override
    public BodyContainer retrieveBodyContainer() {
        return body;
    }

    @Override
    public void setBodyContainer(BodyContainer bodyContainer) {
        this.body = bodyContainer;
    }
}
